import { ComponentType } from './component-types';
import { IGaeaInstance, IGaeaAll } from '../../types';
// import { IFormAsConditionType } from '@/plugins/bpmn/propertiesConfigPannel/pannels/condition/components/utils';
// import { GetWorkplaceList } from '@/plugins/form/components-material/group-travel/services';
// import { GroupPriceExtra } from '@/plugins/form/components-material/group-business/price/design/extra-setting';
// import { RangePickerExtraSetting } from '@/plugins/form/components-material/rangepicker/extra-setting';
// import { ProxyContractSaleExtra } from '@/plugins/form/components-material/group-proxy-service/contract-sale/design/extra-setting';

interface IExtraProperties extends IterateAny {
  bpmCondition?: boolean;
  formCondition?: boolean;
  detailComponent?: ComponentType; // 对应的详情组件
  formPermissionHandler?: (
    formObj: IGaeaAll,
    item: IGaeaInstance,
    others?: any
  ) => any;
  // bpmConditionHandler?: (
  //   formObj: IGaeaAll,
  //   item: IGaeaInstance,
  //   others?: any,
  // ) => IFormAsConditionType[];
  // formConditionHandler?: (
  //   formObj: IGaeaAll,
  //   item: IGaeaInstance,
  //   others?: any,
  // ) => IFormAsConditionType[];
  // will change formObj
  beforeSubmitHandler?: (
    formObj: IGaeaAll,
    item: IGaeaInstance,
    others?: any
  ) => void;
  beforeParseDetailHandler?: (
    formObj: IGaeaAll,
    item: IGaeaInstance,
    others?: any
  ) => void;
}

// const groupTravelPermissionHandler = (
//   formObj: IGaeaAll,
//   item: IGaeaInstance,
//   others?: any,
// ) => {
//   if (!item.childs) return {};
//   return {
//     key: 'payDate',
//     required: formObj['payDate']?.data?.props.required,
//     subName: others.parentName
//       ? `${formObj['payDate']?.data?.props.name}-${formObj['payDate'].data.props.name}`
//       : '',
//     name: `差旅费报销申请-${formObj['payDate']?.data?.props.name}`,
//     disableEdit: false,
//     permissionField:
//       formObj['payDate']?.data?.props.bpmnPermission?.[others.approvalNodeId],
//   };
// };

// const groupTravelBpmConditionHandler = (
//   formObj: IGaeaAll,
//   item: IGaeaInstance,
//   others?: any,
// ) => {
//   return [
//     {
//       componentType: ComponentType.RadioSelect,
//       label: formObj['workplace'].data.props.name,
//       value: 'workplace',
//       optionsHandler: async () => {
//         let result = await GetWorkplaceList();
//         return result?.list;
//       },
//     },
//   ];
// };

// const groupBuinessBpmConditionHandler = (
//   formObj: IGaeaAll,
//   item: IGaeaInstance,
//   others?: any,
// ) => {
//   let options = formObj['isUseSeal']?.data.props.options.toJS
//     ? formObj['isUseSeal']?.data.props.options.toJS()
//     : formObj['isUseSeal']?.data.props.options;
//   return [
//     {
//       componentType: ComponentType.RadioSelect,
//       label: formObj['isUseSeal']?.data.props.name,
//       value: 'isUseSeal',
//       options,
//     },
//   ];
// };

export const ComponentExtraProperties: { [index: string]: IExtraProperties } = {
  [ComponentType.RadioSelect]: {
    bpmCondition: true, // 当设置为require的时候，是否能够作为条件
    formCondition: true, // 当设置为require的时候，是否能够作为条件
  },
  [ComponentType.CheckboxSelect]: {
    formCondition: true, // 当设置为require的时候，是否能够作为条件
  },
  [ComponentType.DeptSelect]: {
    // formCondition: true, // 当设置为require的时候，是否能够作为条件
    bpmCondition: true, // 当设置为require的时候，是否能够作为条件
  },
  [ComponentType.InputMoney]: {
    bpmCondition: true, // 当设置为require的时候，是否能够作为条件
  },
  [ComponentType.InputNumber]: {
    bpmCondition: true, // 当设置为require的时候，是否能够作为条件
  },
  [ComponentType.ImagePicker]: {
    detailComponent: ComponentType.ImagePicker,
  },
  [ComponentType.FilePicker]: {
    detailComponent: ComponentType.FilePicker,
  },
  [ComponentType.Detail]: {
    detailComponent: ComponentType.Detail,
  },
  [ComponentType.LaberDetail]: {
    detailComponent: ComponentType.LaberDetail,
  },
  [ComponentType.LaberOutSiderDetail]: {
    detailComponent: ComponentType.LaberOutSiderDetail,
  },
  [ComponentType.LabelInSideDetail]: {
    detailComponent: ComponentType.LabelInSideDetail,
  },
  [ComponentType.OfficialMatter]: {
    detailComponent: ComponentType.OfficialMatter,
  },
  [ComponentType.RelatedMattersTable]: {
    detailComponent: ComponentType.RelatedMattersTable,
  },
  // [ComponentType.RangePicker]: RangePickerExtraSetting,

  // ['gaea-group-travel-apply-reimbursement']: {
  //   formPermissionHandler: groupTravelPermissionHandler,
  //   bpmConditionHandler: groupTravelBpmConditionHandler,
  // },
  // [ComponentType.GroupBusinessContractSell]: {
  //   bpmConditionHandler: groupBuinessBpmConditionHandler,
  // },
  // [ComponentType.GroupBusinessPrice]: GroupPriceExtra,

  // [ComponentType.ProxyContractSale]: ProxyContractSaleExtra,
};
